/**
 * 题目：2025/09/14 考试 T1 印度
 * 完成时间: 2025-09-14 17:00
 * 思路：
 */
#include <bits/stdc++.h>
#define range(i, b, e) for (auto i(b); i != (e); i++)
#define rep(i, b, e) for (auto i(b); i <= (e); i++)
#define req(i, b, e) for (auto i(b); i >= (e); i--)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> Pii;

const int N = 1e6;
int n, m;
string str[N+5], ans[N+5];

void paint(int i, int j) {
	str[i][j] = str[i][j-1] = str[i][j+1] = str[i-1][j] = str[i+1][j] = 'x';
	ans[i][j-1] = '1';
}

int main() {
	freopen("indian.in", "r", stdin);
	freopen("indian.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cin >> n >> m;
	rep(i, 0, m+1) str[0] += '.', str[n+1] += '.';
	rep(i, 1, n) cin >> str[i], str[i] = '.' + str[i] + '.';
	rep(i, 1, n) rep(j, 1, m) ans[i] += str[i][j] == '#' ? '0' : '.';
	rep(i, 1, n) rep(j, 1, m) {
		if (str[i][j] != '#') continue;
		if (str[i+1][j] == '#') paint(i+1, j);
		else if (str[i][j+1] != '#') paint(i, j+1);
		else paint(i, j);
	}
	rep(i, 1, n) cout << ans[i] << '\n';
	return 0;
}
